/*
 * Created on 2006-02-06
 */
package dk.aiszone.lang.utils;

import java.util.LinkedHashMap;
import java.util.Map;

import junit.framework.TestCase;

/**
 * Test cases for the <code>MapUtils</code> class.
 * 
 * @author <a href="mailto:ais@mail.dk">Ais</a>
 */
public class MapUtilsTest extends TestCase {

    /**
     * Simple toString test
     */
    public void testToString() {
        Map<String, Boolean> testMap = new LinkedHashMap<String, Boolean>();

        testMap.put("A", Boolean.FALSE);
        testMap.put("B", Boolean.TRUE);
        testMap.put("C", Boolean.TRUE);
        testMap.put("D", Boolean.FALSE);

        String toString = MapUtils.toString(testMap);

        assertEquals("toString", "{ [A = false], [B = true], [C = true], [D = false] }", toString);
    }
    
    /**
     * Simple toString test with array values
     */
    public void testToString_WithArray() {
        Map<String, Boolean[]> testMap = new LinkedHashMap<String, Boolean[]>();

        testMap.put("A", new Boolean[] { Boolean.FALSE, Boolean.FALSE });
        testMap.put("B", new Boolean[] { Boolean.TRUE, Boolean.FALSE });
        testMap.put("C", new Boolean[] { Boolean.FALSE, Boolean.TRUE });
        testMap.put("D", new Boolean[] { Boolean.TRUE, Boolean.TRUE });

        String toString = MapUtils.toString(testMap);

        assertEquals("toString", "{ [A = (false, false)], [B = (true, false)], [C = (false, true)], [D = (true, true)] }", toString);
    }

    /**
     * Simple toString test
     */
    public void testToString_empty() {
        Map<String, Boolean> testMap = new LinkedHashMap<String, Boolean>();

        String toString = MapUtils.toString(testMap);

        assertEquals("toString", "{  }", toString);
    }

    /**
     * Simple toString test
     */
    public void testToString_null() {
        String toString = MapUtils.toString(null);

        assertEquals("toString", "", toString);
    }
}
